<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <title></title>
  <style>
    #col {
      width: 300px;
      height: 100px;
      background-color: #ccc;
    }
  </style>
</head>

<body>
  <button onclick="getCol('blue')">蓝色</button>
  <button onclick="getCol('red')">红色</button>
  <button onclick="getCol('#ff6699')">紫色</button>
  <div id="col"></div>

  <script>

    function getCol(cole) {
      document.getElementById("col").style.background = cole;
    }

  </script>
</body>

</html>